package github.data_structure.list;

/**
 * @Author: DRevelation
 * @Date: 2020/12/24 20:27
 * 顺序表
 */
public class SeqList<T> implements LList<T> {

    private Object[] element;
    private int len;

    public SeqList(int size) {
        this.element = new Object[size];
        this.len = 0;
    }
    public SeqList() {
        this(64);
    }

    @Override
    public boolean isEmpty() {
        return this.len == 0;
    }

    @Override
    public int length() {
        return this.len;
    }

    @Override
    public T get(int i) {
        if (i >= 0 && i < this.len) {
            return (T) this.element[i];
        }
        return null;
    }

    @Override
    public void set(int i, T x) {
        if (x == null) {
            return;
        }
        if (i >=0 && i < this.len) {
            this.element[i] = x;
        } else {
            throw new IndexOutOfBoundsException(i + "");
        }
    }

    @Override
    public void insert(int i, T x) {
        if (x == null) {
            return;
        }
        if (this.len == element.length) {

        }
    }

    @Override
    public void append(T x) {

    }

    @Override
    public T remove(int i) {
        return null;
    }

    @Override
    public void removeall() {

    }

    @Override
    public T search(T key) {
        return null;
    }
}
